﻿/******************************************************************************
 * 
 * Announce: CSharpKit, Basic algorithms, components and definitions.
 *           Copyright (C) ShenYongchen.
 *           All rights reserved.
 *   Author: 申永辰.郑州 (shenyczz@163.com)
 *  WebSite: http://gitee.com/shenyczz/csharp_csk
 *
 * THIS CODE IS LICENSED UNDER THE MIT LICENSE (MIT).
 * THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 
 * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
 * IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
 * PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 * 
******************************************************************************/
using System;
using System.Runtime.InteropServices;

using HFILE = System.IntPtr;
using PVOID = System.IntPtr;
using codes_handle = System.IntPtr;
using codes_context = System.IntPtr;
using codes_iterator = System.IntPtr;
using codes_multi_handle = System.IntPtr;
using codes_string_list = System.IntPtr;


namespace CSharpKit.Native.ECCODES
{
    // 
    // Iterating on latitude/longitude/values
    // 
    partial class eccodes
    {
        /// <summary>
        /// <para>功能: Create a new geoiterator from a GRIB handle, using current geometry and values. </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="handle"> the handle from which the geoiterator will be created </param>
        /// <param name="flags"> flags for future use. </param>
        /// <param name="error"> error code </param>
        /// <returns> the new geoiterator, NULL if no geoiterator can be created </returns>
        /// <remarks>
        /// 原型: codes_iterator* codes_grib_iterator_new(const codes_handle* h, unsigned long flags, int* error) <br/>
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_iterator_new")]
        public extern static codes_iterator codes_grib_iterator_new(codes_handle handle, ulong flags, out int error);


        /// <summary>
        /// <para>功能: Get latitude/longitude and data values. </para>
        /// <para>说明: 
        /// The latitudes, longitudes and values arrays must be properly allocated by the caller.
        /// Their required dimension can be obtained by getting the value of the integer key "numberOfPoints".
        /// </para>
        /// </summary>
        /// <param name="handle"> handle from which geography and data values are taken </param>
        /// <param name="lats"> returned array of latitudes </param>
        /// <param name="lons"> returned array of longitudes </param>
        /// <param name="values"> returned array of data values </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_grib_get_data(const codes_handle* h, double* lats, double* lons, double* values) <br/>
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_get_data")]
        public extern static int codes_grib_get_data(codes_handle handle, ref double[] lats, ref double[] lons, ref double[] values);


        /// <summary>
        /// <para>功能: Get the next value from a geoiterator. </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="iterator"> the geoiterator </param>
        /// <param name="lat"> on output latitude in degree </param>
        /// <param name="lon"> on output longitude in degree </param>
        /// <param name="value"> on output value of the point </param>
        /// <returns> positive value if successful, 0 if no more data are available. </returns>
        /// <remarks>
        /// 原型: int codes_grib_iterator_next(codes_iterator* i, double* lat, double* lon, double* value)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_iterator_next")]
        public extern static int codes_grib_iterator_next(codes_iterator iterator, out double lat, out double lon, out double value);


        /// <summary>
        /// <para>功能: Get the previous value from a geoiterator. </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="iterator"> the geoiterator </param>
        /// <param name="lat"> on output latitude in degree </param>
        /// <param name="lon"> on output longitude in degree </param>
        /// <param name="value"> on output value of the point </param>
        /// <returns> positive value if successful, 0 if no more data are available </returns>
        /// <remarks>
        /// 原型: int codes_grib_iterator_previous(codes_iterator* i, double* lat, double* lon, double* value)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_iterator_previous")]
        public extern static int codes_grib_iterator_previous(codes_iterator iterator, out double lat, out double lon, out double value);


        /// <summary>
        /// <para>功能: Test procedure for values in a geoiterator. </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="iterator"> the geoiterator </param>
        /// <returns> boolean, 1 if the iterator still nave next values, 0 otherwise. </returns>
        /// <remarks>
        /// 原型: int codes_grib_iterator_has_next(codes_iterator* i)
        /// </remarks>
        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_iterator_has_next")]
        public extern static bool codes_grib_iterator_has_next(codes_iterator iterator);


        /// <summary>
        /// <para>功能: Test procedure for values in a geoiterator.</para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="iterator"> the geoiterator </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_grib_iterator_reset(codes_iterator* i)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_iterator_reset")]
        public static extern int codes_grib_iterator_reset(codes_iterator iterator);


        /// <summary>
        /// <para>功能: Frees the geoiterator from memory. </para>
        /// <para>说明: </para>
        /// </summary>
        /// <param name="iterator"> the geoiterator </param>
        /// <returns> 0 if OK, integer value on error </returns>
        /// <remarks>
        /// 原型: int codes_grib_iterator_delete(codes_iterator* i)
        /// </remarks>
        [DllImport(_dllname_, CharSet = CharSet.Auto, EntryPoint = "codes_grib_iterator_delete")]
        public static extern int codes_grib_iterator_delete(codes_iterator iterator);
        


        // {{END}}
    }

}
